﻿package com.tudou.home.newskin.containers
{
    import com.tudou.home.newskin.buttons.*;
    import com.tudou.home.newskin.consts.*;
    import com.tudou.home.newskin.events.*;
    import com.tudou.home.newskin.model.*;
    import com.tudou.home.utils.*;
    import com.tudou.net.*;
    import com.tudou.skin.*;
    import com.tudou.track.*;
    import com.tudou.utils.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;

    public class NextItemSprite extends Sprite implements IRelativeVideo, IInitVideo, ITransFinished
    {
        private var relativeList:Array;
        private var nextVideoInfo:IBaseVideoInfo;
        private var title:HrefIconText;
        private var nextIndex:int = 0;
        private var frame1:PhotoFrame;
        private var share:SimpleButton;
        private var replay:SimpleButton;
        private var baseVideoInfo:IBaseVideoInfo;
        private static const LEFT_RIGHT_BETWEEN:uint = 10;

        public function NextItemSprite()
        {
            var _loc_1:* = NewSkinConsts.SHARE_WIDTH;
            var _loc_2:* = NewSkinConsts.SHARE_HEIGHT;
            var _loc_3:* = NewSkinConsts.FRAME1_WIDTH;
            var _loc_4:* = NewSkinConsts.FRAME1_HEIGHT;
            var _loc_5:* = _loc_3 + LEFT_RIGHT_BETWEEN;
            var _loc_6:* = _loc_1 - _loc_5;
            frame1 = new PhotoFrame();
            frame1.setFrameColorAlpha(NewSkinConsts.FRAME1_FRAMELINE_COLOR, 1);
            frame1.setWidthHeight(_loc_3, _loc_4);
            frame1.x = 0;
            frame1.y = 0;
            addChild(frame1);
            title = new HrefIconText(NewSkinConsts.SHARE_WIDTH - _loc_5);
            title.textFormat = new TextFormat("宋体", 15, 16777215);
            title.addEventListener(MouseEvent.CLICK, nextItemHlr);
            title.x = _loc_5;
            title.y = 0;
            addChild(title);
            share = new ShareSmallBTN();
            share.x = title.x;
            share.y = frame1.y + _loc_4 - share.height;
            addChild(share);
            replay = new ReplaySmallBTN();
            replay.x = title.x;
            replay.y = share.y - replay.height - 10;
            addChild(replay);
            RectDisplayUtil.drawRect(graphics, _loc_1, _loc_2, 0, 0);
            replay.addEventListener(MouseEvent.CLICK, replyHlr);
            share.addEventListener(MouseEvent.CLICK, shareHlr);
            return;
        }// end function

        public function set showTransFinished(param1:Boolean) : void
        {
            return;
        }// end function

        public function setPlaylistSingleContinue(param1:Boolean) : void
        {
            return;
        }// end function

        private function shareHlr(event:MouseEvent) : void
        {
            dispatchEvent(new SkinEvent(SkinEvent.BUTTON_LOG, SkinButtonCode.MORE_SHARE));
            openMoreShare(baseVideoInfo.iid);
            return;
        }// end function

        public function setRelativeList(param1:Array) : void
        {
            if (param1 == null || param1.length == 0)
            {
                return;
            }
            relativeList = param1;
            mainItem();
            return;
        }// end function

        public function startTransFinishTimeout() : void
        {
            return;
        }// end function

        private function nextItemHlr(event:MouseEvent) : void
        {
            FullScreen.getInst().exitFullScreen();
            SingleItemOpenUrl.openType = SingleItemOpenUrl.TRANS_FINISH_CLICK;
            dispatchEvent(new SkinEvent(SkinEvent.SINGLE_THIS_INDEX, nextIndex));
            return;
        }// end function

        private function replyHlr(event:MouseEvent) : void
        {
            dispatchEvent(new SkinEvent(SkinEvent.BUTTON_LOG, SkinButtonCode.REPLAY));
            dispatchEvent(new SkinEvent(SkinEvent.REPLAY));
            return;
        }// end function

        public function stopTransFinishTimeout() : void
        {
            return;
        }// end function

        private function mainItem() : void
        {
            var _loc_1:IBaseVideoInfo = null;
            if (!baseVideoInfo || !relativeList)
            {
                return;
            }
            nextIndex = 0;
            if (nextIndex >= relativeList.length)
            {
                nextIndex = 0;
            }
            _loc_1 = relativeList[nextIndex] as IBaseVideoInfo;
            nextVideoInfo = _loc_1;
            if (frame1.isLoaded)
            {
                return;
            }
            frame1.load(_loc_1.frame1URL);
            title.title = _loc_1.title;
            title.refresh();
            return;
        }// end function

        public function setBaseVideoInfo(param1:IBaseVideoInfo) : void
        {
            baseVideoInfo = param1;
            mainItem();
            return;
        }// end function

    }
}
